import java.io.File;
import java.util.HashMap;

class location extends DataMiningManik
{
	private String stateId;
	private String stateName;
	private HashMap county;
	
	static 
	{
		(new File("countyFiles")).mkdir();
	}
	
	location(String id, String name)
	{
		stateId = id;
		stateName = name;
		county = populateCountyInformation();
	}
	
	public HashMap getCounty() { return county; }
	public String getStateId() { return stateId;}
	
	private HashMap populateCountyInformation()
	{
		HashMap hm = new HashMap();
		File state = new File("countyFiles" + File.separator + stateName);

		// if the file is already present on the disk...read it from there. No need to fetch it again
		if (!(state.isFile() && state.exists() && state.length() != 0))
		{
			// download county information
			openConnection(COUNTY_URL + stateId, state);
		}
		
		// populate county inforamtion
		if (state.length() != 0L)
			hm = populate(state, "\t");
		else
			System.out.println("ERROR creating county file ?");
		
		return hm;
	}
}

